const Order = require('./backend/src/models/Order');

// 测试订单号生成
async function testOrderNumberGeneration() {
  console.log('=== 测试订单号生成系统 ===\n');
  
  // 测试不同类型的订单号生成
  const testCases = [
    { order_type: 'dine_in', is_guest: false, description: '堂食会员订单' },
    { order_type: 'dine_in', is_guest: true, description: '堂食游客订单' },
    { order_type: 'takeaway', is_guest: false, description: '外带会员订单' },
    { order_type: 'takeaway', is_guest: true, description: '外带游客订单' },
    { order_type: 'delivery', is_guest: false, description: '配送会员订单' },
    { order_type: 'delivery', is_guest: true, description: '配送游客订单' },
    { order_type: 'reservation_dine_in', is_guest: false, description: '预订堂食会员订单' },
    { order_type: 'reservation_dine_in', is_guest: true, description: '预订堂食游客订单' },
    { order_type: 'reservation_takeaway', is_guest: false, description: '预订外带会员订单' },
    { order_type: 'reservation_takeaway', is_guest: true, description: '预订外带游客订单' }
  ];
  
  for (const testCase of testCases) {
    try {
      const orderNumber = await Order.generateOrderNumber(testCase.order_type, testCase.is_guest);
      console.log(`${testCase.description}: ${orderNumber}`);
    } catch (error) {
      console.error(`${testCase.description} 生成失败:`, error.message);
    }
  }
}

testOrderNumberGeneration().catch(console.error);